package midend.IR_Type;

import java.util.List;

//函数的中间代码的类
public class IR_Func implements IR_Type{
    private IR_Type Return_Type;
    private List<IR_Type> Params_Type;
    private int Params_Count;

    public IR_Func(IR_Type ret,List<IR_Type> params){
        this.Return_Type = ret;
        this.Params_Type = params;
        this.Params_Count = params.size();
    }

    public int get_Params_Count(){
        return this.Params_Count;
    }

    public IR_Type get_Return_Type(){
        return this.Return_Type;
    }

    public List<IR_Type> get_Params_Type() {
        return this.Params_Type;
    }

    public IR_Type get_Param_Type(int i){
        return this.Params_Type.get(i);
    }
    @Override
    public String get_TypeName() {
        StringBuilder s = new StringBuilder();
        s.append("(");
        for(IR_Type tmp:Params_Type){
            s.append(tmp.get_TypeName() + " ");
        }
        s.append(")");
        return s.toString();
    }

    @Override
    public int get_Const_Type() {
        return IR_Const.IR_ConstFunction;
    }

    @Override
    public String toString() {
        return "IR_Func{" +
                "Return_Type=" + Return_Type +
                ", Params_Type=" + Params_Type +
                ", Params_Count=" + Params_Count +
                '}';
    }
}
